package com.bravo.bravomerchant.activities;

import com.bravo.bravomerchant.R;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;

/**
 * @author jiawl
 * 
 */
public class SplashActivity extends Activity {

	private static String TAG = SplashActivity.class.getName();
	private static long SLEEP_TIME = 2; // Sleep for some time
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		this.requestWindowFeature(Window.FEATURE_NO_TITLE); // Removes title bar
		this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN); // Removes notification bar
		
		setContentView(R.layout.activity_splash);
		IntentLauncher launcher = new IntentLauncher();
		launcher.start();
	}

	/**
	 * Sleep for some time and than start new activity.
	 */
	private class IntentLauncher extends Thread {
		
		@Override
		public void run() {
		
			try {
				// Sleeping
				Thread.sleep(SLEEP_TIME * 1000);
			} catch (Exception e) {
				
				Log.e(TAG, e.getMessage());
			}

			// Start main activity
			Intent intent = new Intent(SplashActivity.this, LoginActivity.class);
			SplashActivity.this.startActivity(intent);
			// Animation can not work
			//SplashActivity.this.overridePendingTransition(R.anim.splash_enter, R.anim.splash_out);
			SplashActivity.this.finish();
		}
	}

}
